package com.lfec.dividiraconta;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class PessoaMainAdapter extends ArrayAdapter<Pessoa> {
	
	LayoutInflater inflater;
	
	public PessoaMainAdapter(Context context){
		super(context, R.layout.pessoa_main_row);
		
		inflater = (LayoutInflater)context.getSystemService
				(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.pessoa_main_row, parent, false);
		}
		
		TextView name = (TextView) convertView.findViewById(R.id.pessoaMainRowName);
		TextView value = (TextView) convertView.findViewById(R.id.valorRowCheck);
		TextView percentValue = (TextView) convertView.findViewById(R.id.valor10RowCheck);
		
		Pessoa pes = this.getItem(position);
		name.setText(pes.getNome());
		
		String rs = getContext().getString(R.string.rs);
		value.setText(rs + " " + pes.getValor());
		percentValue.setText(rs + " " + pes.getValor10());
		
		
		return convertView;
	}
	
	

}
